"""empty message

Revision ID: 8df4cc122a16
Revises: aa94ccbf920b
Create Date: 2025-04-15 16:16:05.636824

"""

from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "8df4cc122a16"
down_revision: Union[str, None] = "aa94ccbf920b"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("message_chain_message_id_idx", table_name="message_chains")
    op.drop_table("message_chains")
    op.add_column(
        "message_agent_thoughts",
        sa.Column("status", sa.String(length=255), nullable=True),
    )
    op.drop_index(
        "message_agent_thought_message_chain_id_idx",
        table_name="message_agent_thoughts",
    )
    op.drop_column("message_agent_thoughts", "message_chain_id")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "message_agent_thoughts",
        sa.Column("message_chain_id", sa.CHAR(length=32), nullable=True),
    )
    op.create_index(
        "message_agent_thought_message_chain_id_idx",
        "message_agent_thoughts",
        ["message_chain_id"],
        unique=False,
    )
    op.drop_column("message_agent_thoughts", "status")
    op.create_table(
        "message_chains",
        sa.Column("id", sa.CHAR(length=32), nullable=False),
        sa.Column("message_id", sa.CHAR(length=32), nullable=True),
        sa.Column("type", sa.VARCHAR(length=255), nullable=True),
        sa.Column("input", sa.TEXT(), nullable=True),
        sa.Column("output", sa.TEXT(), nullable=True),
        sa.Column("created_at", sa.DATETIME(), nullable=True),
        sa.PrimaryKeyConstraint("id", name="message_chain_pkey"),
    )
    op.create_index("message_chain_message_id_idx", "message_chains", ["message_id"], unique=False)
    # ### end Alembic commands ###
